package com.lg.edu.controller;

import com.lg.edu.service.ValidCodeService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/code")
public class ValidCodeController {

    @Reference(timeout = 300000)
    private ValidCodeService validCodeService;

    @GetMapping("/create/{email}")
    public Boolean create(@PathVariable("email") String email) {
        return validCodeService.create(email);
    }

    @GetMapping("/validate/{email}/{code}")
    public Integer validate(@PathVariable("email") String email, @PathVariable("code") String code) {
        return validCodeService.validate(email, code);
    }

}
